/*
 * lighting.h
 *
 *  Created on: 24-jun-2009
 *      Author: HPK
 */

#ifndef LIGHTING_H_
#define LIGHTING_H_

#include "light.h"
#include <vector>

class Lighting{
	private:
		GLint max_hw_lights;

		std::vector<Light*> _lights;
		RGBAColor _globalAmbient;
		bool disabled;

		Lighting();
		Lighting(const Lighting&);
		void operator ==(const Lighting&);
	public:
		~Lighting();

		static Lighting& instance();

		Light* createLight(const Point& pos,RGBAColor diffuse,RGBAColor ambient,float cA=1.0f,float lA=0.0f,float qA=0.0f);
		Light* createSpotLight(const Point& pos,RGBAColor diffuse,RGBAColor ambient,Point dir,float cutoff,float cA=1.0f,float lA=0.0f,float qA=0.0f);
		void removeLight(Light* light);

		void disable(){ disabled=true; }
		void enable(){ disabled=false; }

		void globalAmbient(const RGBAColor& color){ _globalAmbient=color; }
		const RGBAColor& globalAmbientRGBA(){ return _globalAmbient; }
		const float* globalAmbient(){ return (float*)&_globalAmbient; }

		void enableLights(const Point& eye,const Point& object);
		void enableAllLights();

		void disableLights();
		std::vector<Light*>::const_iterator lights();
		std::vector<Light*>::const_iterator lights_end();
		bool enableLights(std::vector<Light*>::const_iterator& prev);
};

#endif /* LIGHTING_H_ */
